Apis = {};

/** ********************************************************************************************** 用户 */

{
    Apis.islogin = function(callback) {
        var url = '/support/api/user/checklogin';
        WGetCall(url, {}, function(response) {
            if (response.status == 200) {
                callback(true);
                return;
            }
            callback(false);
        });
    };

    Apis.login = function(par, callback) {
        WJsonCall('/support/api/user/login', par, function(response) {
            if (response.status == 200) {
                callback(true, response.data);
                return;
            }
            callback(false, response.message);
        });
    };

    Apis.loginCode = function(code, callback) {
        WJsonCall('/support/api/user/adminverfy', {code: code}, function(response) {
            callback(response);
        });
    };

    Apis.logout = function(callback) {
        var url = '/support/api/user/logout';
        WGetCall(url, {}, function(response) {
            callback();
        });
    };

    Apis.keepsession = function(callback) {
        var url = '/support/api/keepsession';
        WGetCall(url, {}, function(response) {
            callback && callback();
        });
    };
}

/** ********************************************************************************************** 工作台 */

{
    // Apis.workstation = function (parameter, callback) {
    //     var url = '/support/api/statis/workstation';
    //     WGetCall(url, parameter, function(response) {
    //         callback(response);
    //     });
    // };

    Apis.getConsoleCount = function(parameter, callback) {
        var url = '/support/api/folder/console/index';
        WPostJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
}

/** ********************************************************************************************** 素材管理 */

{

    /**
     * TODO 检查素材名称是否有重复
     */
    Apis.isResExist = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,
            type: condition.type,
            name: condition.name
        };

        // /resource/{bookmode}/{lang}/{type}
        var url = '/support/resource/{0}/{1}/video/check'.format(condition.siteId, condition.lang);
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.getResImages = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,
            type: 'image',
            name: null,
            pageStart: condition.pageStart,
            pageSize: condition.pageSize,
            orders:
                {
                    orders: [
                        {
                            field: 'create_at',
                            ascOrDes: false
                        }
                    ]
                }
        };

        if (condition.orders) {
            parameter.orders.orders = condition.orders;
            // [
            //     {
            //         field: 'name',
            //         ascOrDes: false
            //     }
            // ]
        }

        // /resource/{bookmode}/{lang}/{type}
        var url = '/support/resource/{0}/{1}/image'.format(condition.siteId, condition.lang);
        WJsonCall(url, parameter, function(response) {
            // /resource/{bookmode}/{lang}/{type}/{name}/download
            response.data.forms = response.data.forms.map(function(m) {
                m.url = '/support/res/{0}/{1}/material/pic/{2}'
                    .format(condition.siteId, condition.lang, m.name);
                return m;
            });
            callback(response);
        });
    };

    Apis.getResImagesSearch = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,
            type: 'image',
            name: condition.name,
            pageStart: condition.pageStart,
            pageSize: condition.pageSize,
            orders:
                {
                    orders: [
                        {
                            field: 'create_at',
                            ascOrDes: false
                        }
                    ]
                }
        };

        if (condition.orders) {
            parameter.orders.orders = condition.orders;
            // [
            //     {
            //         field: 'name',
            //         ascOrDes: true
            //     }
            // ]
        }

        // /resource/{bookmode}/{lang}/{type}
        var url = '/support/resource/{0}/{1}/image/search'.format(condition.siteId, condition.lang);
        WJsonCall(url, parameter, function(response) {
            response.data.forms = response.data.forms.map(function(m) {
                m.url = '/support/res/{0}/{1}/material/pic/{2}'
                    .format(condition.siteId, condition.lang, m.name);
                return m;
            });
            callback(response);
        });
    };

    Apis.getResVideos = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,
            type: 'video',
            name: null,
            pageStart: condition.pageStart,
            pageSize: condition.pageSize,
            orders:
                {
                    orders: [
                        {
                            field: 'create_at',
                            ascOrDes: false
                        }
                    ]
                }
        };

        if (condition.orders) {
            parameter.orders.orders = condition.orders;
            // [
            //     {
            //         field: 'name',
            //         ascOrDes: true
            //     }
            // ]
        }

        // /resource/{bookmode}/{lang}/{type}
        var url = '/support/resource/{0}/{1}/video'.format(condition.siteId, condition.lang);
        WJsonCall(url, parameter, function(response) {
            // /resource/{bookmode}/{lang}/{type}/{name}/download
            response.data.forms = response.data.forms.map(function(m) {
                // m.url = '/support/misumires/{0}/{1}/material/mov/{2}'.format(condition.siteId, condition.lang, m.name);
                // m.playurl = '/support/misumires/{0}/{1}/material/mov/{2}'.format(condition.siteId, condition.lang, m.name);
                m.url = '/support/res/{0}/{1}/material/mov/{2}'
                    .format(condition.siteId, condition.lang, m.name);
                m.playurl = '/support/res/{0}/{1}/material/mov/{2}'
                    .format(condition.siteId, condition.lang, m.name);
                return m;
            });
            callback(response);
        });
    };

    Apis.getResVideosSearch = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,
            type: 'video',
            name: condition.name,
            pageStart: condition.pageStart,
            pageSize: condition.pageSize,
            orders:
                {
                    orders: [
                        {
                            field: 'create_at',
                            ascOrDes: false
                        }
                    ]
                }
        };

        if (condition.orders) {
            parameter.orders.orders = condition.orders;
            // [
            //     {
            //         field: 'name',
            //         ascOrDes: true
            //     }
            // ]
        }

        // /resource/{bookmode}/{lang}/{type}
        var url = '/support/resource/{0}/{1}/video/search'.format(condition.siteId, condition.lang);
        WJsonCall(url, parameter, function(response) {
            // /resource/{bookmode}/{lang}/{type}/{name}/download
            response.data.forms = response.data.forms.map(function(m) {
                // m.url = '/support/misumires/{0}/{1}/material/mov/{2}'.format(condition.siteId, condition.lang, m.name);
                // m.playurl = '/support/misumires/{0}/{1}/material/mov/{2}'.format(condition.siteId, condition.lang, m.name);
                m.url = '/support/res/{0}/{1}/material/mov/{2}'
                    .format(condition.siteId, condition.lang, m.name);
                m.playurl = '/support/res/{0}/{1}/material/mov/{2}'
                    .format(condition.siteId, condition.lang, m.name);
                return m;
            });
            callback(response);
        });
    };

    Apis.deleteRes = function (condition, callback) {
        var parameter = {
            type: condition.type
        };
        var url = '/support/resource/{0}'.format(condition.uid);
        WGetCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.deleteResImage = function (condition, callback) {
        condition.type = 0;
        Apis.deleteRes(condition, callback);
    };

    Apis.deleteResVideo = function (condition, callback) {
        condition.type = 1;
        Apis.deleteRes(condition, callback);
    };

    Apis.renameResImage = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,
            type: 'image',

            uid: condition.uid,
            name: condition.name
        };
        var url = '/support/resource/rename';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.renameResVideo = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,
            type: 'video',

            uid: condition.uid,
            name: condition.name
        };
        var url = '/support/resource/rename';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
}

/** ********************************************************************************************** 标签分类 */

{
    Apis.addTagCategoty = function (condition, callback) {
        var parameter = {
            name: condition.name,
            lang: condition.lang,
            siteId: condition.siteId,
        };
        var url = '/support/api/tag/category/create';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.updTagCategoty = function (condition, callback) {
        var parameter = {
            id: condition.id,
            name: condition.name,
        };
        var url = '/support/api/tag/category/update';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.delTagCategoty = function (condition, callback) {
        var parameter = {
            id: condition.id,
        };
        var url = '/support/api/tag/category/delete';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.getTagCategotys = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,

            start: condition.start,
            size: condition.size,
        };
        var url = '/support/api/tag/category/search';
        WJsonCall(url, parameter, function(response) {
            if (response.data == null) {
                response.data = {};
                response.data.catalogs = [];
            }
            callback(response);
        });
    };



    // batch
    Apis.addTagCategotyLangAll = function (condition, callback) {
        var forms = [
            {
                name: '',
                lang: '',
                siteId: ''
            }
        ];
        var parameter = {
            siteId: condition.siteId,
            forms: condition.forms
        };
        var url = '/support/api/tag/categories';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
    Apis.getTagCategotyLangAll = function (condition, callback) {
        var parameter = {
            siteId: condition.siteId,
            lang: condition.lang,
            id: condition.id
        };
        var url = '/support/api/tag/category';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
    Apis.delTagCategotyLangAll = function (condition, callback) {
        var parameter = {
            id: condition.id
        };
        var url = '/support/api/tag/category/del';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
}

/** ********************************************************************************************** 标签 */

{
    Apis.addTag = function (condition, callback) {
        var parameter = {
            tagcatId: condition.tagCatId,
            tag: condition.name,
            lang: condition.lang,
            siteId: condition.siteId,
        };
        var url = '/support/api/tag/create';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.updTag = function (condition, callback) {
        var parameter = {
            id: condition.id,
            name: condition.name,
        };
        var url = '/support/api/tag/update';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.delTag = function (condition, callback) {
        var parameter = {
            id: condition.id,
        };
        var url = '/support/api/tag/delete';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.getTags = function (condition, callback) {
        var parameter = {
            name: condition.name,
            catalogId: condition.catalogId,

            siteId: condition.siteId,
            lang: condition.lang,

            start: condition.start,
            size: condition.size,
        };
        var url = '/support/api/tag/search';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    // batch
    Apis.addTagLangAll = function (condition, callback) {
        var forms = [
            {
                tagcatId: '',
                lang: '',
                siteId: '',
                tag: '',
            }
        ];
        var parameter = {
            tagcatId: condition.tagcatId,
            // lang: condition.lang,
            siteId: condition.siteId,
            forms: condition.forms
        };
        var url = '/support/api/tag/tags';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
    Apis.getTagLangAll = function (condition, callback) {
        //
        // public String lang;
        // public String bookMode;
        // public int catalogId;
        // public int id;
        var parameter = {
            lang: condition.lang,
            siteId: condition.siteId,
            catalogId: condition.tagcatId,
            id: condition.id
        };
        var url = '/support/api/tag/tag';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
    Apis.delTagLangAll = function (condition, callback) {
        var parameter = {
            id: condition.id
        };
        var url = '/support/api/tag/tag/del';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
}

/** ********************************************************************************************** 邮箱设置 */

{

    // public int id;
    // public String stmp;
    // public int siteId;
    // public int port;
    // public String sender;
    // public String password;
    // public String recievers;
    Apis.updEmailSettings = function (condition, callback) {
        var parameter = {
            id: condition.id,
            stmp: condition.stmp,
            siteId: condition.siteId,
            port: condition.port,
            sender: condition.sender,
            password: condition.password,
            recievers: condition.recievers,
        };
        var url = '/support/api/emails';
        WPostJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.getEmailSettings = function (siteId, callback) {
        var parameter = {
            siteid: siteId
        };
        var url = '/support/api/eamils/email';
        WGetCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.testEmailSettings = function (siteId, callback) {
        var parameter = {
            siteid: siteId
        };
        var url = '/support/api/emails/test';
        WGetCall(url, parameter, function(response) {
            callback(response);
        });
    };
}

/** ********************************************************************************************** 文章 */

{
    Apis.getArticleList = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null,
        //     lang: null,
        //
        //     title: null,
        //     articleNo: null,
        //     userId: 0,
        //
        // };

        if (parameter.orders) {
            parameter.orders = {
                orders: parameter.orders
            };
        } else {
            parameter.orders = {
                orders: [
                    {
                        field: 'a.article_no',
                        ascOrDes: true
                    }
                ]
            };
        }

        var url = '/support/api/article/list';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.getArticle = function (parameter, callback) {
        // var parameter = {
        //     id: 0
        // };
        var url = '/support/api/article';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });

        // var response = {
        //     data: {
        //         id: 32,
        //         userId: 0,
        //         articleNo: "D1-2",
        //         title: "UI设置还原",
        //         summary: null,
        //         creator: "管理员",
        //         remark: "<p>摘要D1-2</p>",
        //         fileName: "D1-2",
        //         updateAt: "2018-07-06T07:59:19.000+0000",
        //         bookMode: "Mold",
        //         lang: "zhCN",
        //         flowDescription: [
        //             {
        //                 id: 0,
        //                 articleId: 0,
        //                 tilte: null,
        //                 index: 0,
        //                 lang: null,
        //                 opSamples: null
        //             },
        //             {
        //                 id: 0,
        //                 articleId: 0,
        //                 tilte: null,
        //                 index: 0,
        //                 lang: null,
        //                 opSamples: null
        //             }
        //         ],
        //         articleVideo: [
        //             {
        //                 id: 25,
        //                 articleId: 32,
        //                 videoUrl: null,
        //                 videoId: 0,
        //                 index: 0
        //             }
        //         ],
        //         tags: [
        //             {
        //                 id: 35,
        //                 articleId: 32,
        //                 tagId: 1,
        //                 tagcatId: 0,
        //                 tag: null,
        //                 lang: "zhCN"
        //             },
        //             {
        //                 id: 36,
        //                 articleId: 32,
        //                 tagId: 4,
        //                 tagcatId: 0,
        //                 tag: null,
        //                 lang: "zhCN"
        //             },
        //             {
        //                 id: 37,
        //                 articleId: 32,
        //                 tagId: 10,
        //                 tagcatId: 0,
        //                 tag: null,
        //                 lang: "zhCN"
        //             }
        //         ],
        //         relatedArticle: [
        //             {
        //                 id: 24,
        //                 articleId: 32,
        //                 relateArticleId: 29,
        //                 relateArticleTitle: null,
        //                 index: 1,
        //                 lang: null
        //             }
        //         ],
        //         relatedVideo: [ ]
        //     }
        // };
        //
        // callback(response);

    };

    Apis.createArticle = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null,
        //     lang: null,
        //
        //     articleNo: null,
        //     fileName: null,
        //     title: null,
        //
        //     summary: null,
        //     flow2OpSample: null,
        //     articleVideo: null,
        //     remark: null,
        //     relatedArticle: null,
        //     relatedVideo: null,
        //     tags: null,
        //
        // };
        var url = '/support/api/article/create';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.updateArticle = function (parameter, callback) {
        // var parameter = {
        //     id: null,
        //
        //     bookMode: null,
        //     lang: null,
        //
        //     articleNo: null,
        //     fileName: null,
        //     title: null,
        //
        //     summary: null,
        //     flow2OpSample: null,
        //     articleVideo: null,
        //     remark: null,
        //     relatedArticle: null,
        //     relatedVideo: null,
        //     tags: null,
        //
        // };
        var url = '/support/api/article/create';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.deleteArticle = function (parameter, callback) {
        // var parameter = {
        //     id: 0
        // };
        var url = '/support/api/article/delete';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };


    Apis.isExistArticle = function (parameter, callback) {
        // var parameter = {
        //     id: 0
        // };
        var url = '/support/api/article/exist';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.setCanModify = function (parameter, callback) {
        var url = '/support/api/article/can/modify';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };


}

/** ********************************************************************************************** 目录 */

{

    Apis.createFolder = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null,
        //     lang: null,
        //
        //     name: null,
        //     type: 1, // Item(0), Category(1), Hot(2);
        //     sort: 0,
        // };
        var url = '/support/api/folder/create';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.updateFolder = function (parameter, callback) {
        // var parameter = {
        //     id: null,
        //     name: null,
        //     type: 1, // Item(0), Category(1), Hot(2);
        // };
        var url = '/support/api/folder/update';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.deleteFolder = function (parameter, callback) {
        // var parameter = {
        //     id: null,
        //     type: 1, // Item(0), Category(1), Hot(2);
        // };
        var url = '/support/api/folder/delete';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.getFolders = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null,
        //     lang: null
        // };
        var url = '/support/api/folder/list';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.addArticleToFolder = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null
        //     lang: null,
        //
        //     folderId: null,
        //     folderType: null
        //     articles: [] // {articleId: 0, sort: 0}
        // };
        var url = '/support/api/folder/article/add';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.deleteArticleFromFolder = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null
        //     lang: null,
        //
        //     folderId: null,
        //     folderType: null
        //     articleIds: []
        // };
        var url = '/support/api/folder/article/remove';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.getArticlesIndex = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null,
        //     lang: null
        // };
        var url = '/support/api/folder/articles';
        WJsonCall(url, parameter, function(response) {
            response.data = response.data.map(function(data) {
                data.articles = data.articles.filter(function(article) {
                    return article.articleNo != null;
                }).sort(function(a, b) {
                    return a.sort - b.sort;
                });
                return data;
            });
            callback(response);
        });
    };

    Apis.moveArticleSort = function (parameter, callback) {
        // var parameter = {
        //     forms: [
        //         {
        //             bookMode: null,
        //             lang: null,
        //             // Item(0), Category(1), Hot(2);
        //             lang: folderType,
        //             lang: folderId,
        //             lang: arctileId,
        //             lang: sort,
        //         }
        //     ]
        // }
        var url = '/support/api/folder/article/sort';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.moveFolderSort = function (parameter, callback) {
        // var parameter = {
        //     forms: [
        //         {
        //             bookMode: null,
        //             lang: null,
        //             lang: folderId,
        //             lang: sort,
        //         }
        //     ]
        // }
        var url = '/support/api/folder/sort';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    // batch
    Apis.createFolderLangAll = function (parameter, callback) {
        var cnForm = {
            siteId: null,
            lang: null,
            type: 1, // Item(0), Category(1), Hot(2);
            name: '',
            sort: 0,

        };
        // var parameter = {
        //     bookMode: null,
        //     type: 1, // Item(0), Category(1), Hot(2);
        //     cnForm: '',
        //     jpForm: '',
        //     enForm: '',
        //     twForm: '',
        //     krForm: '',
        //     thForm: '',
        // };
        var url = '/support/api/folder/batch';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.getFolderLangAll = function (parameter, callback) {
        // /* 0 : item 2 : catalog null : all */
        // public Integer  folderType;
        // public int id;
        // public String bookMode;
        // public String lang;
        // var parameter = {
        //     bookMode: null,
        //     folderType: 1,
        //     lang: '',
        //     id: ''
        // };
        var url = '/support/api/folder';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.delFolderLangAll = function (parameter, callback) {
        // /* 0 : item 2 : catalog null : all */
        // public Integer  folderType;
        // public int id;
        // public String bookMode;
        // public String lang;
        // var parameter = {
        //     id: [],
        //     type: 0
        // };
        var url = '/support/api/folder/del';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

}

/** ********************************************************************************************** 账号 */

{
    Apis.getAccounts = function (parameter, callback) {
        // var parameter = {
        //     name: null
        // };
        var url = '/support/api/user/list';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.createAccount = function (parameter, callback) {
        // var parameter = {
        //     loginName: null,
        //     userName: null,
        //     password: null
        // };
        var url = '/support/api/user/create';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.updateAccount = function (parameter, callback) {
        // var parameter = {
        //     uid: null,
        //     loginName: null,
        //     userName: null,
        //     password: null
        // };
        var url = '/support/api/user/update';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.deleteAccount = function (parameter, callback) {
        // var parameter = {
        //     uid: 0
        // };
        var url = '/support/api/user/delete';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
}

/** ********************************************************************************************** 发布 */

{

    Apis.publish = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null,
        //     lang: null
        //     inside: 'true' // 内部参考
        // };
        var url = '/support/api/static/publish';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.currentVersion = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null,
        //     lang: null
        // };
        var url = '/support/api/static/current';
        WJsonCall(url, parameter, function(response) {
            response.data.forEach(function(m) {
                m.siteId = m.siteId.toLowerCase();
            });
            callback(response);
        });
    };

    Apis.historyVersion = function (parameter, callback) {
        // var parameter = {
        //     bookMode: null,
        //     lang: null
        // };
        var url = '/support/api/static/history';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

}

/** ********************************************************************************************** 同步 */
{

    Apis.sync = function (parameter, callback) {
        // // 0 syncSelect 1 syncAll
        // public int syncType;
        // // 1 item 2 catalog 3 hotspot 4 relateVideo 5 relateArticle 6 tag
        // public List<Integer> selectItems;
        // // book mode
        // public String bookMode;
        // // select article numbers ( Integer -> articleNoId, String -> articleName)
        // public Map<String, Integer> cnSelectArticleNos;
        // var parameter = {
        //     bookMode: '',
        //     syncType: 0,
        //     selectItems: [],
        //     cnSelectArticleNos: {}
        // };
        var url = '/support/api/sync';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

}

/** ********************************************************************************************** 咨询 */

{
    Apis.getAdvices = function (parameter, callback) {
        // var parameter = {
        //     name: null
        // };
        var url = '/support/api/infos/filter';
        WJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.deleteAdvice = function (id, callback) {
        // var parameter = {
        //     uid: 0
        // };
        var url = '/support/api/infos/' + id;
        WDeleteJsonCall(url, {}, function(response) {
            callback(response);
        });
    };
}

/** ********************************************************************************************** 账号 */

{
    Apis.getDomains = function (parameter, callback) {
        var url = '/support/api/sites';
        WGetCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.createDomain = function (parameter, callback) {
        var url = '/support/api/sites';
        WPostJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };

    Apis.activeDomain = function (parameter, callback) {
        // var parameter = {
        //     uid: null,
        //     loginName: null,
        //     userName: null,
        //     password: null
        // };
        var url = '/support/api/sites/active';
        WPostJsonCall(url, parameter, function(response) {
            callback(response);
        });
    };
    //
    // Apis.deleteDomain = function (parameter, callback) {
    //     // var parameter = {
    //     //     uid: 0
    //     // };
    //     var url = '/support/api/user/delete';
    //     WJsonCall(url, parameter, function(response) {
    //         callback(response);
    //     });
    // };
}




















